<?php

include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/robokassa.php');

$errors = '';
$result = false;
$rb = new robokassa();

$id_cart = $_REQUEST['InvId'];
$amount = $_REQUEST['OutSum'];
$rb_password1 = Configuration::get('RB_PASSWORD1');
$rb_sign = md5("$amount:$id_cart:$rb_password1");

if(strtoupper($_REQUEST['SignatureValue'])==strtoupper($rb_sign)) {
    echo $rb->getL('success');
    $id_order = Order::getOrderByCartId($id_cart);//new Order($rb->currentOrder);
    if (!$id_order)
	    Tools::redirect('history.php');
    $order = new Order(intval($id_order));
    Tools::redirectLink(__PS_BASE_URI__.'order-confirmation.php?id_cart='.$id_cart.'&id_module='.$rb->id.'&key='.$order->secure_key);
}
?>